<template>
    <div class="image">
        <el-button type="primary" @click="isToggle">打开/关闭影像</el-button>
    </div>
</template>

<script setup>
import { ref, onMounted, inject } from 'vue'
let $map = null
onMounted(() => {
    $map = inject("$map")
})
//初始化image状态
var isImage = false
function isToggle() {
    let layers = []
    layers = $map.getLayers().array_
    var obj = layers.find(item => item.get("title") == "天地图影像层")
    var obj_cav = layers.find(item => item.get("title") == "天地图影像注记图层")
    isImage = !isImage
    if (isImage) {
        obj.setVisible(false)
        obj_cav.setVisible(false)
    } else {
        obj.setVisible(true)
        obj_cav.setVisible(true)
    }
}
</script>

<style lang="scss" scoped>
.image {
    button {
        position: fixed;
        bottom: 10px;
        right: 15px;
        z-index: 99;
    }
}
</style>